package com.freewater.library.lending.reader.model.event;

import com.freewater.library.common.domain.DomainEvent;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.apache.commons.lang3.Validate;

import java.time.LocalDateTime;

/**
 * 读者被暂停借书事件
 */
@Getter
@EqualsAndHashCode
public class ReaderDisabledEvent implements DomainEvent {
    /**
     * 读者关联的读者Id
     */
    private final Long readerId;
    /**
     * 读者被暂停借阅发生时间
     */
    private final LocalDateTime occurAt;

    public ReaderDisabledEvent(Long readerId) {
        this(readerId, LocalDateTime.now());
    }

    public ReaderDisabledEvent(Long readerId, LocalDateTime occurAt) {
        Validate.notNull(readerId, "读者关联的读者Id不能为空");
        Validate.notNull(occurAt, "读者被暂停借阅发生时间不能为空");
        this.readerId = readerId;
        this.occurAt = occurAt;
    }

    @Override
    public LocalDateTime occurAt() {
        return occurAt;
    }
}
